package com.enterprise.projectManager.rope;

import com.enterprise.projectManager.model.QualityCheck;
import org.springframework.data.jpa.repository.JpaRepository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface QualityCheckRope extends JpaRepository<QualityCheck,String> {
    @Query("SELECT q from QualityCheck q where " +
            "(:qualityCheckId is null or q.checkId = :qualityCheckId )"+
            "and (:checkResult is null or q.checkResult = :checkResult )"+
            "and (:checkStartDate is null or q.checkDate >= :checkStartDate )"+
            "and (:checkEndDate is null or q.checkDate <= :checkEndDate )"+
            "and (:projectId is null or q.project.projectId = :projectId )"


    )
    List<QualityCheck> filterQualityCheck(@Param(value = "qualityCheckId") String qualityCheckId,
                                          @Param(value = "checkResult") String qualityResult,
                                          @Param(value = "checkStartDate") Date qualityStartDate,
                                          @Param(value = "checkEndDate") Date qualityEndDate,
                                          @Param(value = "projectId") String projectId

    );


}
